package com.baizhi.service.impl;

import com.baizhi.dao.PlayedDao;
import com.baizhi.entity.Played;
import com.baizhi.service.PlayedService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 播放历史(Played)表服务实现类
 *
 * @author makejava
 * @since 2021-09-26 23:22:14
 */
@Transactional
@Service("playedService")
public class PlayedServiceImpl extends ServiceImpl<PlayedDao, Played> implements PlayedService {

    @Autowired
    private PlayedDao playedDao;

    /**
     * 播放次数
     *
     * @param videoId
     * @return
     */
    @Override
    public Integer queryByVideoId(Integer videoId) {
        LambdaQueryWrapper<Played> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Played::getVideoId, videoId);
        Integer integer = playedDao.selectCount(queryWrapper);
        return integer;
    }
}

